package eclipse.util.modeltools;
import java.awt.event.*;

import javax.swing.*;
public class ModelToolkit implements ActionListener
{
	private JButton btnAddVertex;
	private JFrame	window;
	
	public ModelToolkit()
	{
		btnAddVertex = new JButton("Add Vertex");
		btnAddVertex.addActionListener(this);
		window = new JFrame("Model toolkit");
		window.setSize(120, 100);
		window.add(btnAddVertex);		
		window.setVisible(true);
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	public void actionPerformed(ActionEvent arg0) 
	{
		String point = JOptionPane.showInputDialog(null, "Input coordinates as 3D point");
		if(point == null)
			return;
		point = point.trim();
		if(point.startsWith("(") && point.endsWith(")"))
		{
			point = point.replace("(", "");
			point = point.replace(")", "");
			point = point.replace(" ", "");
			String verts[] = point.split(",");
			ModelEditor.addVerts(Integer.parseInt(verts[0]),
					Integer.parseInt(verts[1]),
					Integer.parseInt(verts[2]));
		}
	}
	
	
}
